// 自建数据中心
// 共同富裕
// store是一个数据仓库
export const initialState = {
    loading: true,
    movies: [],
    errorMessage: null
}
// reducer 函数 state(初始状态) action(活动)
export const reducer = (state, action) => {
    console.log(action, '-------');
    switch (action.type) { //做了什么事？
        case "SEARCH_MOVIES_SUCCESS":
            return {
                ...state,
                loading: false,
                movies: action.payload
            }
        case 'SEARCH_MOVIES_ERROR':
            return {
                ...state,
                loading: false,
                movies: [],
                errorMessage: action.payload
            }
        case 'SEARCH_MOVIES_LOADING':
            return {
                ...state,
                loading: true,
                movies: []
            }
        default:
            return state
    }
}